#============================================================
#    Main
#============================================================
# - datetime: 2023-01-11 00:38:23
#============================================================
extends Node2D


@onready 
var base_role := $base_role as BaseRole


#============================================================
#  内置
#============================================================
func _ready() -> void:
	# 输出属性信息
	Aspect.around(base_role.property_management.newly_added_property, func(property, value):
		Log.info([ "[", base_role, "]", "新增属性:", property, " > ", value ])
	)
	
	Aspect.after(base_role.property_management.property_changed, func(property, previous, current):
		Log.info([ "[", base_role, "]", property, "属性发生改变:", previous, " -> ", current ])
	)
	
	Aspect.around(base_role.died, func(data):
		Log.info(["[", base_role, "]", "已死亡"])
	)
	
	# 属性数据
	var role_property = {
		Const.Property.HEALTH: 10,
		Const.Property.MOVE_SPEED: 100,
		Const.Property.ATTACK: 2,
	}
	# 进行增加初始属性
	var value
	for property in role_property:
		value = role_property[property]
		base_role.property_management.add_property(property, value)
	
	# 修改 health 属性
	base_role.property_management.add_property(Const.Property.HEALTH, 1)
	base_role.property_management.sub_property(Const.Property.HEALTH, 5)
	base_role.property_management.sub_property(Const.Property.HEALTH, 10)



#============================================================
#  连接信号
#============================================================
func _on_add_health_pressed() -> void:
	base_role.property_management.add_property(Const.Property.HEALTH, 1)

